package io.renren.modules.erp.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.modules.erp.entity.*;
import io.renren.modules.erp.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * Description
 *
 * @Author: cjl
 * @Date: 2019/1/25 14:50
 */
@Mapper
public interface DepotHeadMapperEx {
    List<DepotHeadVo4List> selectByConditionDepotHead(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("creatorArray") String[] creatorArray,
            @Param("number") String number,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("materialParam") String materialParam,
            @Param("depotIds") String depotIds,
             Page<DepotHeadVo4List> page,
            @Param("payType") String payType,
            @Param("status") String status,
            @Param("transportType") String transportType,
            @Param("serviceType") String serviceType,
            @Param("userName") String userName,
            @Param("deliverDate") String deliverDate,
            @Param("billType") String billType,
            @Param("salesDate") String salesDate,
            @Param("stockType") String stockType,
            @Param("deliveryType") String deliveryType,
            @Param("deliveryBillNo") String deliveryBillNo,
            @Param("salesBillNo") String salesBillNo,
            @Param("externalNumber") String externalNumber,
            @Param("buyer") String buyer,
            @Param("purchaseStockBillNo") String purchaseStockBillNo,
            @Param("purchaseSalesBillNo") String purchaseSalesBillNo,
            @Param("organName") String organName,
            @Param("accountSalesBillno") String accountSalesBillno);


    List<DepotHeadVo4List> selectByTransferList(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("creatorArray") String[] creatorArray,
            @Param("number") String number,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("materialParam") String materialParam,
            @Param("depotIds") String depotIds,
            Page<DepotHeadVo4List> page,
            @Param("status") String status
       );

    List<DepotHeadVo4List> getCheckList(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("creatorArray") String[] creatorArray,
            @Param("number") String number,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("materialParam") String materialParam,
            @Param("depotIds") String depotIds,
            Page<DepotHeadVo4List> page,
            @Param("status") String status,
            @Param("checkStatus") String checkStatus,
            @Param("depotId") String depotId
    );



    List<SellOrder> selectOrderProduct(

            Page<SellOrder> page,
            @Param("begin") String begin,
            @Param("end") String end,
            @Param("orderSn") String orderSn,
            @Param("memberUsername") String memberUsername,
            @Param("receiverName") String receiverName,
            @Param("receiverPhone") String receiverPhone,
            @Param("status") String status,
            @Param("isOrderNumber") String isOrderNumber
            );

    List<ReturnOrder> selectReturnOrderProduct(

            Page<ReturnOrder> page,
            @Param("createTime") String createTime,
            @Param("orderSn") String orderSn,
            @Param("serviceNumber") String serviceNumber,
            @Param("memberCompany") String memberCompany,
            @Param("receiveMan") String receiveMan,
            @Param("status") String status,
            @Param("type") String type,
            @Param("isReturnNumber") String isReturnNumber,
            @Param("receivePhone") String receivePhone
    );

    List<ProductExtendVo> selectByOrderSn(

            Page<ProductExtendVo> page,
            @Param("orderSn") String orderSn
    );

    List<ReturnProduct> selectByServiceNumber(

            Page<ReturnProduct> page,
            @Param("serviceNumber") String serviceNumber
    );


    List<DepotHeadVo4List> selectByConditionDepotHead2(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("creatorArray") String[] creatorArray,
            @Param("number") String number,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("materialParam") String materialParam,
            @Param("depotIds") String depotIds,
            Page<DepotHeadVo4List> page,
            @Param("payType") String payType,
            @Param("status") String status,
            @Param("transportType") String transportType,
            @Param("serviceType") String serviceType,
            @Param("userName") String userName,
            @Param("deliverDate") String deliverDate,
            @Param("billType") String billType,
            @Param("salesDate") String salesDate,
            @Param("stockType") String stockType,
            @Param("deliveryType") String deliveryType,
            @Param("deliveryBillNo") String deliveryBillNo,
            @Param("salesBillNo") String salesBillNo,
            @Param("externalNumber") String externalNumber,
            @Param("organName") String organName);



    Long countsByDepotHead(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("creatorArray") String[] creatorArray,
            @Param("number") String number,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("materialParam") String materialParam,
            @Param("depotIds") String depotIds);

    String findMaterialsListByHeaderId(
            @Param("id") Long id);

    List<DepotHeadVo4InDetail> findByAll(
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("type") String type,
            @Param("pid") Integer pid,
            @Param("dids") String dids,
            @Param("oId") Integer oId,
            Page<DepotHeadVo4InDetail> page);

    int findByAllCount(
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("type") String type,
            @Param("pid") Integer pid,
            @Param("dids") String dids,
            @Param("oId") Integer oId);

    List<DepotHeadVo4InOutMCount> findInOutMaterialCount(
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("type") String type,
            @Param("pid") Integer pid,
            @Param("dids") String dids,
            @Param("oId") Integer oId,
            Page<DepotHeadVo4InOutMCount> page);

    int findInOutMaterialCountTotal(
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("type") String type,
            @Param("pid") Integer pid,
            @Param("dids") String dids,
            @Param("oId") Integer oId);

    List<DepotHeadVo4StatementAccount> findStatementAccount(
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("organId") Integer organId,
            @Param("supType") String supType,
            Page<DepotHeadVo4StatementAccount> page);

    int findStatementAccountCount(
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime,
            @Param("organId") Integer organId,
            @Param("supType") String supType);

    BigDecimal findAllMoney(
            @Param("supplierId") Integer supplierId,
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("modeName") String modeName,
            @Param("endTime") String endTime);

    BigDecimal findAllOtherMoney(
            @Param("supplierId") Integer supplierId,
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("endTime") String endTime);

    List<DepotHeadVo4List> getDetailByNumber(
            @Param("number") String number);

    void updateBuildOnlyNumber();
    /**
     * 获得一个全局唯一的数作为订单号的追加
     * */
    Long getBuildOnlyNumber(@Param("seq_name") String seq_name);

    int batchDeleteDepotHeadByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);

    List<DepotHead> getDepotHeadListByAccountIds(@Param("accountIds") String[] accountIds);

    List<DepotHead> getDepotHeadListByOrganIds(@Param("organIds") String[] organIds);

    List<DepotHead> getDepotHeadListByCreator(@Param("creatorArray") String[] creatorArray);

    BigDecimal getBuyAndSaleStatistics(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("hasSupplier") Integer hasSupplier,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime);

    BigDecimal getBuyAndSaleRetailStatistics(
            @Param("type") String type,
            @Param("subType") String subType,
            @Param("hasSupplier") Integer hasSupplier,
            @Param("beginTime") String beginTime,
            @Param("endTime") String endTime);
}
